package com.tjsinfo.tjsoa.system.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.json.JSONArray;
import org.json.JSONObject;

import com.tjsinfo.tjsoa.system.bo.ITSystemRolesGroupBO;
import com.tjsinfo.tjsoa.system.vo.TSystemPost;
import com.tjsinfo.tjsoa.system.vo.TSystemRolesGroup;

/**
 * 权限组树
 * @author Administrator
 *
 */
public class RolesGroupTreeAction extends Action{
	private ITSystemRolesGroupBO systemRolesGroupBO;

	public ITSystemRolesGroupBO getSystemRolesGroupBO() {
		return systemRolesGroupBO;
	}

	public void setSystemRolesGroupBO(ITSystemRolesGroupBO systemRolesGroupBO) {
		this.systemRolesGroupBO = systemRolesGroupBO;
	}

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		List<TSystemRolesGroup> list = systemRolesGroupBO.selectAllRolesGroup();
		JSONArray array = new JSONArray();
		for (TSystemRolesGroup systemRolesGroup : list) {
			JSONObject object = new JSONObject();
			object.put("id", systemRolesGroup.getId());
			object.put("text", systemRolesGroup.getGroupname());
			object.put("leaf", true);
			object.put("ordernumber", systemRolesGroup.getOrdernumber());
			array.put(object);
		}
		response.getWriter().print(array);
		return null;
	}
	
	
}
